'use strict';

module.exports = function countSameElements(collection) {
  let arr=[];
  let result={};
  for(let i of collection)
  {
    if(!result[i])
    {
      result[i]={};
      result[i].key=i;
      result[i].count=1;
    }
    else
    result[i].count++;
  }
    for(let j in result)
    arr.push(result[j]);
    
    return arr;
    


    

  
}
